﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;

namespace GroceryInventory
{
    public class InventoryItem
    {

        public Guid ID { get; set; }

        public string ItemName  
        {
            get { return _ItemName; }
            set { _ItemName = value; }
        }
        private string _ItemName;
        
        public string Description
        {
            get { return _Description; }
            set { _Description = value; }
        }
        private string _Description;

        public UnitsType Units
        {
            get { return _Units; }
            set { _Units = value; }
        }
        private UnitsType _Units;

        public string UnitsString
        {
            get { return _Units.ToString(); }
        }
        
        public int Count
        {
            get { return _Count; }
            set { _Count = value; }
        }
        private int _Count;
        
        public InventoryItem(string name, string description, int count, int units)
        {
            ID = Guid.NewGuid();
            _ItemName = name;
            _Description = description;
            _Count = count;
            _Units = (UnitsType)units;
        }
         
    public InventoryItem(string id, string name, string description, int count, int units)
    {
        ID = Guid.Parse(id);
            _ItemName = name;
            _Description = description;
            _Count = count;
            _Units = (UnitsType)units;
        }

        public InventoryItem()
        {}
    }

        public enum UnitsType
        {
            Weight = 0,
            Count = 1
        }

    public class EnumToArrayConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            return Enum.GetValues(value as Type);
        }
        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            return null; 
        }
    }
}
